NetCon to count spikes


In [1]:
%pylab inline


Populating the interactive namespace from numpy and matplotlib

In [2]:
from neuron import h
h.load_file('stdrun.hoc')
h.tstop = 500

Cell 1


In [3]:
cell1 = h.Section(name = 'cell1')
cell1.L = cell1.diam = 10


Rm = 150e3 # 150 MOhms*cm^2

cell1.insert('hh')
cell1.insert('pas')

cell1.gnabar_hh = 0.25 
cell1.gl_hh = 1/Rm 
cell1.el_hh = h.v_init




# Current injection 
stim = h.IClamp(0.5, sec = cell1)
stim.amp = 0.1
stim.dur = 200
stim.delay = 150

Create hoc Vectors to record time and potential


In [4]:
time, voltage1 = h.Vector(), h.Vector()
time.record(h._ref_t)
voltage1.record(cell1(0.5)._ref_v)


Out[4]:
1.0

Create a NetCon object to count spikes


In [5]:
mynetcon = h.NetCon( cell1(0.5)._ref_v, None, sec = cell1)
myhocvector = h.Vector()
mynetcon.record(myhocvector)


Out[5]:
0.0

Run the simulation


In [6]:
h.run()


Out[6]:
0.0

Obtain spike times in a vector


In [7]:
np.array(myhocvector) # spike times


Out[7]:
array([ 151.125,  163.075,  174.275,  185.45 ,  196.65 ,  207.825,
        219.   ,  230.175,  241.35 ,  252.55 ,  263.725,  274.9  ,
        286.075,  297.275,  308.45 ,  319.625,  330.8  ,  341.975])

In [8]:
plt.plot(time, voltage1, lw=1)
plt.xlabel('Time (ms)'), plt.ylabel('Voltage (mV)');



In [ ]: